#ifndef FUNCTIONPARSERWRAPPER_HPP
#define FUNCTIONPARSERWRAPPER_HPP

#include "fparser.hh"
#include "globals.hpp"
#include <string>

namespace hms
{

class FunctionParserWrapper
{
private:
	static constexpr auto m_vars {
		"x, y, z, t, dt,"
		"x_dom, y_dom, z_dom, val_dom"
	};
	/* declared mutable because FunctionParser::Eval() writes to error value 
	 * data member */
	mutable FunctionParser m_parser;
	std::string m_functionString;
	
public:
	/* default ctor defines useful constants (pi, e, g) */
	FunctionParserWrapper();
	FunctionParserWrapper( std::string, bool optimise = false );
	
	int parse( std::string, bool optimise = false );
	
	double eval(
		double x=0, double y=0, double z=0, double t=0, double dt=0,
		double x_dom=0, double y_dom=0, double z_dom=0, double val_dom=0
	) const;

	const std::string& functionString() const;

	const FunctionParser& parser() const;

	static constexpr auto& allVars(){ return m_vars; }
};



} // end namespace hms

#endif